Added reference counting to animations. A web browser may want to share a
authorFederico Mena Quintero <federico@helixcode.com>
Sun, 2 Jan 2000 03:59:22 +0000 (03:59 +0000)
committerArturo Espinosa <unammx@src.gnome.org>
Sun, 2 Jan 2000 03:59:22 +0000 (03:59 +0000)
2000-01-01  Federico Mena Quintero  <federico@helixcode.com>

* gdk-pixbuf/gdk-pixbuf.h (GdkPixbufAnimation): Added reference
counting to animations.  A web browser may want to share a single
copy of an animated GIF if it appears multiple times in a web
page, for example.

* gdk-pixbuf/gdk-pixbuf-animation.c: New file.  Moved the
animation functions here.
(gdk_pixbuf_animation_new_from_file): Prettified.  Return a NULL
animation if the loader does not support multiframe loading and
the single-frame load returned NULL.  Check that the filename is
not NULL.  Updated inline documentation.
(gdk_pixbuf_animation_ref): New function.
(gdk_pixbuf_animation_unref): New function.
Removed gdk_pixbuf_animation_destroy() in favor of reference
counting.

* gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_new_from_file):
Prettified.  Made ref_count assertion more paranoid.  Check that
the filename is not NULL.
(gdk_pixbuf_get_module): Use guchar * and guint for buffer and
size, respectively.
(gdk_pixbuf_new_from_xpm_data): Changed the "data" argument to
const char **.

* gdk-pixbuf/io-gif.c (image_load_animation): Create the animation
with a reference count of 1.

* gdk-pixbuf/Makefile.am (libgdk_pixbuf_la_SOURCES): Added
gdk-pixbuf-animation.c.

* doc/tmpl/animation.sgml: Populated.  It is still missing a
description of the overlay modes.

* doc/gdk-pixbuf-sections.txt: Added the animation section.  Moved
the canvas item section to the end, as it will be moved later to
gnome-libs.

* doc/gdk-pixbuf.sgml: Added the animation section.

* doc/Makefile.am (tmpl_sources): Added tmpl/animation.sgml.

22 files changed:
docs/reference/gdk-pixbuf/Makefile.am
docs/reference/gdk-pixbuf/gdk-pixbuf-decl.txt
docs/reference/gdk-pixbuf/gdk-pixbuf-sections.txt
docs/reference/gdk-pixbuf/gdk-pixbuf.sgml
docs/reference/gdk-pixbuf/tmpl/animation.sgml [new file with mode: 0644]
docs/reference/gdk-pixbuf/tmpl/from-drawables.sgml
docs/reference/gdk-pixbuf/tmpl/gdk-pixbuf-loader.sgml
docs/reference/gdk-pixbuf/tmpl/rendering.sgml
docs/reference/gdk-pixbuf/tmpl/util.sgml
gdk-pixbuf/ChangeLog
gdk-pixbuf/Makefile.am
gdk-pixbuf/gdk-pixbuf-animation.c [new file with mode: 0644]
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/gdk-pixbuf-io.h
gdk-pixbuf/gdk-pixbuf-loader.c
gdk-pixbuf/gdk-pixbuf-loader.h
gdk-pixbuf/gdk-pixbuf.c
gdk-pixbuf/gdk-pixbuf.h
gdk-pixbuf/io-gif.c
gdk/gdkpixbuf-drawable.c
gtk/gdk-pixbuf-loader.c
gtk/gdk-pixbuf-loader.h

index 6879618c9d2e02a71c352afb2e5fa9835fa59547..40d2a83956136b615af5261d14289aed7104b2a3 100644 (file)
@@ -17,6 +17,7 @@ HTML_DIR=$(datadir)/gnome/html
 TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
 
 tmpl_sources =                                 \
+       tmpl/animation.sgml
        tmpl/creating.sgml                      \
        tmpl/file-loading.sgml                  \
        tmpl/from-drawables.sgml                \
index a5246c9a8acb06de0271d886cc9da1b36a54a923..be6b6adab4ed57d882dbf090586e4ef85d58af4f 100644 (file)
@@ -6,7 +6,9 @@ GdkPixbuf *pixbuf, gpointer user_data
 <USER_FUNCTION>
 <NAME>ModuleUpdatedNotifyFunc</NAME>
 <RETURNS>void </RETURNS>
-GdkPixbuf *pixbuf, gpointer user_data, guint x, guint y, guint width, guint height
+GdkPixbuf *pixbuf, gpointer user_data,
+                                         guint x, guint y,
+                                         guint width, guint height
 </USER_FUNCTION>
 <STRUCT>
 <NAME>GdkPixbufModule</NAME>
@@ -18,12 +20,15 @@ struct GdkPixbufModule {
        gboolean (* format_check) (guchar *buffer, int size);
        GModule *module;
        GdkPixbuf *(* load) (FILE *f);
-        GdkPixbuf *(* load_xpm_data) (const gchar **data);
+        GdkPixbuf *(* load_xpm_data) (const char **data);
 
         /* Incremental loading */
-        gpointer   (* begin_load)    (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, gpointer user_data);
-        void       (* stop_load)     (gpointer context);
-        gboolean   (* load_increment)(gpointer context, const gchar *buf, guint size);
+
+        gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func,
+                                ModuleUpdatedNotifyFunc update_func,
+                                gpointer user_data);
+        void (* stop_load) (gpointer context);
+        gboolean (* load_increment) (gpointer context, const guchar *buf, guint size);
 
        /* Animation loading */
        GdkPixbufAnimation *(* load_animation) (FILE *f);
@@ -32,7 +37,7 @@ struct GdkPixbufModule {
 <FUNCTION>
 <NAME>gdk_pixbuf_get_module</NAME>
 <RETURNS>GdkPixbufModule  *</RETURNS>
-gchar           *buffer,gint             size
+guchar *buffer, guint size
 </FUNCTION>
 <FUNCTION>
 <NAME>gdk_pixbuf_load_module</NAME>
@@ -88,7 +93,7 @@ void
 <FUNCTION>
 <NAME>gdk_pixbuf_loader_write</NAME>
 <RETURNS>gboolean  </RETURNS>
-GdkPixbufLoader *loader,const gchar     *buf,size_t           count
+GdkPixbufLoader *loader,const guchar    *buf,size_t           count
 </FUNCTION>
 <FUNCTION>
 <NAME>gdk_pixbuf_loader_get_pixbuf</NAME>
@@ -114,19 +119,9 @@ GdkPixbufLoader *loader
 <STRUCT>
 <NAME>GdkPixbufAnimation</NAME>
 </STRUCT>
-<ENUM>
-<NAME>GdkPixbufFrameAction</NAME>
-typedef enum
-{
-       GDK_PIXBUF_FRAME_RETAIN,
-       GDK_PIXBUF_FRAME_DISPOSE,
-       GDK_PIXBUF_FRAME_REVERT
-} GdkPixbufFrameAction;
-</ENUM>
 <STRUCT>
 <NAME>GdkPixbuf</NAME>
-struct GdkPixbuf
-{
+struct GdkPixbuf {
        /* Reference count */
        int ref_count;
 
@@ -134,23 +129,41 @@ struct GdkPixbuf
        ArtPixBuf *art_pixbuf;
 };
 </STRUCT>
+<ENUM>
+<NAME>GdkPixbufFrameAction</NAME>
+typedef enum {
+       GDK_PIXBUF_FRAME_RETAIN,
+       GDK_PIXBUF_FRAME_DISPOSE,
+       GDK_PIXBUF_FRAME_REVERT
+} GdkPixbufFrameAction;
+</ENUM>
 <STRUCT>
 <NAME>GdkPixbufFrame</NAME>
-struct GdkPixbufFrame
-{
+struct GdkPixbufFrame {
+       /* The pixbuf with this frame's image data */
        GdkPixbuf *pixbuf;
 
-       gushort x_offset;
-       gushort y_offset;
-       guint delaytime;
+       /* Offsets for overlaying onto the animation's area */
+       int x_offset;
+       int y_offset;
+
+       /* Frame duration in ms */
+       int delay_time;
+
+       /* Overlay mode */
        GdkPixbufFrameAction action;
 };
 </STRUCT>
 <STRUCT>
 <NAME>GdkPixbufAnimation</NAME>
-struct GdkPixbufAnimation
-{
+struct GdkPixbufAnimation {
+       /* Reference count */
+       int ref_count;
+
+       /* Number of frames */
         int n_frames;
+
+       /* List of GdkPixbufFrame structures */
         GList *frames;
 };
 </STRUCT>
@@ -217,7 +230,7 @@ ArtPixFormat format, gboolean has_alpha, int bits_per_sample,int width, int heig
 <FUNCTION>
 <NAME>gdk_pixbuf_new_from_file</NAME>
 <RETURNS>GdkPixbuf  *</RETURNS>
-const char        *filename
+const char *filename
 </FUNCTION>
 <FUNCTION>
 <NAME>gdk_pixbuf_new_from_data</NAME>
@@ -227,7 +240,7 @@ guchar *data,ArtPixFormat format,gboolean has_alpha,int width, int height,int ro
 <FUNCTION>
 <NAME>gdk_pixbuf_new_from_xpm_data</NAME>
 <RETURNS>GdkPixbuf  *</RETURNS>
-const gchar      **data
+const char **data
 </FUNCTION>
 <FUNCTION>
 <NAME>gdk_pixbuf_add_alpha</NAME>
@@ -264,12 +277,17 @@ GdkPixbuf *dest,GdkDrawable *src, GdkColormap *cmap,int src_x, int src_y,int des
 <FUNCTION>
 <NAME>gdk_pixbuf_animation_new_from_file</NAME>
 <RETURNS>GdkPixbufAnimation  *</RETURNS>
-const char         *filename
+const char *filename
+</FUNCTION>
+<FUNCTION>
+<NAME>gdk_pixbuf_animation_ref</NAME>
+<RETURNS>void  </RETURNS>
+GdkPixbufAnimation *animation
 </FUNCTION>
 <FUNCTION>
-<NAME>gdk_pixbuf_animation_destroy</NAME>
+<NAME>gdk_pixbuf_animation_unref</NAME>
 <RETURNS>void  </RETURNS>
-GdkPixbufAnimation *animation,gboolean            free_frames
+GdkPixbufAnimation *animation
 </FUNCTION>
 <MACRO>
 <NAME>GNOME_TYPE_CANVAS_PIXBUF</NAME>
index 9bf5b214c0ab1030777d844da1e29da1b94c0a80..bd2af9551527eaa0a7f136393e8a3391780178a6 100644 (file)
@@ -51,17 +51,13 @@ gdk_pixbuf_add_alpha
 </SECTION>
 
 <SECTION>
-<FILE>gnome-canvas-pixbuf</FILE>
-GNOME_CANVAS_PIXBUF
-<TITLE>GnomeCanvasPixbuf</TITLE>
-<SUBSECTION Standard>
-GNOME_TYPE_CANVAS_PIXBUF
-GNOME_IS_CANVAS_PIXBUF
-gnome_canvas_pixbuf_get_type
-GNOME_CANVAS_PIXBUF_CLASS
-GNOME_IS_CANVAS_PIXBUF_CLASS
-<SUBSECTION Private>
-GnomeCanvasPixbuf
+<FILE>animation</FILE>
+GdkPixbufFrameAction
+GdkPixbufFrame
+GdkPixbufAnimation
+gdk_pixbuf_animation_new_from_file
+gdk_pixbuf_animation_ref
+gdk_pixbuf_animation_unref
 </SECTION>
 
 <SECTION>
@@ -71,6 +67,7 @@ GDK_PIXBUF_LOADER
 gdk_pixbuf_loader_new
 gdk_pixbuf_loader_write
 gdk_pixbuf_loader_get_pixbuf
+gdk_pixbuf_loader_get_animation
 gdk_pixbuf_loader_close
 <SUBSECTION Standard>
 GDK_TYPE_PIXBUF_LOADER
@@ -81,3 +78,17 @@ GDK_IS_PIXBUF_LOADER_CLASS
 <SUBSECTION Private>
 GdkPixbufLoader
 </SECTION>
+
+<SECTION>
+<FILE>gnome-canvas-pixbuf</FILE>
+GNOME_CANVAS_PIXBUF
+<TITLE>GnomeCanvasPixbuf</TITLE>
+<SUBSECTION Standard>
+GNOME_TYPE_CANVAS_PIXBUF
+GNOME_IS_CANVAS_PIXBUF
+gnome_canvas_pixbuf_get_type
+GNOME_CANVAS_PIXBUF_CLASS
+GNOME_IS_CANVAS_PIXBUF_CLASS
+<SUBSECTION Private>
+GnomeCanvasPixbuf
+</SECTION>
index b3e8b2cab1954862d36f49a70e3696078ff0f88e..b95e72f7fe2fc305c36cd0208d4be46cea033332 100644 (file)
@@ -6,8 +6,9 @@
 <!entity gdk-pixbuf-rendering SYSTEM "sgml/rendering.sgml">
 <!entity gdk-pixbuf-from-drawables SYSTEM "sgml/from-drawables.sgml">
 <!entity gdk-pixbuf-util SYSTEM "sgml/util.sgml">
-<!entity GnomeCanvasPixbuf SYSTEM "sgml/gnome-canvas-pixbuf.sgml">
+<!entity gdk-pixbuf-animation SYSTEM "sgml/animation.sgml">
 <!entity GdkPixbufLoader SYSTEM "sgml/gdk-pixbuf-loader.sgml">
+<!entity GnomeCanvasPixbuf SYSTEM "sgml/gnome-canvas-pixbuf.sgml">
 ]>
 
 <book>
@@ -50,7 +51,8 @@
     &gdk-pixbuf-rendering;
     &gdk-pixbuf-from-drawables;
     &gdk-pixbuf-util;
-    &GnomeCanvasPixbuf;
+    &gdk-pixbuf-animation;
     &GdkPixbufLoader;
+    &GnomeCanvasPixbuf;
   </reference>
 </book>
diff --git a/docs/reference/gdk-pixbuf/tmpl/animation.sgml b/docs/reference/gdk-pixbuf/tmpl/animation.sgml
new file mode 100644 (file)
index 0000000..8a5d558
--- /dev/null
@@ -0,0 +1,86 @@
+<!-- ##### SECTION Title ##### -->
+Animations
+
+<!-- ##### SECTION Short_Description ##### -->
+Animations as multi-frame structures.
+
+<!-- ##### SECTION Long_Description ##### -->
+  <para>
+    The GdkPixbuf library provides a simple mechanism to load and
+    represent animations, primarily animated GIF files.  Animations
+    are represented as lists of #GdkPixbufFrame structures.  Each
+    frame structure contains a #GdkPixbuf structure and information
+    about the frame's overlay mode and duration.
+  </para>
+
+
+<!-- ##### SECTION See_Also ##### -->
+  <para>
+    #GdkPixbufLoader
+  </para>
+
+
+<!-- ##### ENUM GdkPixbufFrameAction ##### -->
+  <para>
+    
+  </para>
+
+@GDK_PIXBUF_FRAME_RETAIN: 
+@GDK_PIXBUF_FRAME_DISPOSE: 
+@GDK_PIXBUF_FRAME_REVERT: 
+
+<!-- ##### STRUCT GdkPixbufFrame ##### -->
+  <para>
+    This structure describes a frame in a #GdkPixbufAnimation.  Each
+    frame consists of a #GdkPixbuf, an offset of the frame within the
+    animation's bounding box, a duration, and an overlay mode or
+    action.
+  </para>
+
+@pixbuf: The frame's image contents.
+@x_offset: X offset of the frame inside the animation's bounding box.
+@y_offset: Y offset of the frame inside the animation's bounding box.
+@delay_time: Duration of the frame in milliseconds.
+@action: Overlay mode.
+
+<!-- ##### STRUCT GdkPixbufAnimation ##### -->
+  <para>
+    This structure describes an animation, which is represented as a
+    list of #GdkPixbufFrame structures.
+  </para>
+
+@ref_count: Reference count.
+@n_frames: Number of frames in the animation.
+@frames: List of #GdkPixbufFrame structures.
+
+<!-- ##### FUNCTION gdk_pixbuf_animation_new_from_file ##### -->
+<para>
+
+</para>
+
+@filename: 
+@Returns: 
+
+
+<!-- ##### FUNCTION gdk_pixbuf_animation_ref ##### -->
+<para>
+
+</para>
+
+@animation: 
+
+
+<!-- ##### FUNCTION gdk_pixbuf_animation_unref ##### -->
+<para>
+
+</para>
+
+@animation: 
+
+
+<!--
+Local variables:
+mode: sgml
+sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
+End:
+-->
index e8efb59d97f4b3a34e2142be0b0fa05a8884aed2..3415bcb123240e419f0d852385569306178178df 100644 (file)
@@ -13,13 +13,11 @@ Getting parts of a drawable's image data into a pixbuf.
     transferred from the X server to the client program and converted.
   </para>
 
-
 <!-- ##### SECTION See_Also ##### -->
   <para>
     #GdkPixbuf, gdk_image_get()
   </para>
 
-
 <!-- ##### FUNCTION gdk_pixbuf_get_from_drawable ##### -->
 <para>
 
@@ -36,10 +34,11 @@ Getting parts of a drawable's image data into a pixbuf.
 @height: 
 @Returns: 
 
-
 <!--
 Local variables:
 mode: sgml
 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
 End:
 -->
+
+
index e9052c94be922015ff9ba0d2772dc43fad74061e..5638a1f34535b37b12c4a48f02f34927d9d04ab8 100644 (file)
@@ -54,6 +54,15 @@ Application-driven image loading.
 @Returns: 
 
 
+<!-- ##### FUNCTION gdk_pixbuf_loader_get_animation ##### -->
+<para>
+
+</para>
+
+@loader: 
+@Returns: 
+
+
 <!-- ##### FUNCTION gdk_pixbuf_loader_close ##### -->
 <para>
 
index 68e5f616eb633a32aa344e74192449dfca444ab3..a3f86c3701d9c27035e729dd92a5c1faa6453a12 100644 (file)
@@ -104,8 +104,7 @@ In the future it will do full alpha compositing.
 @dest_y: 
 @width: 
 @height: 
-@alpha_threshold: 
-<!--
+@alpha_threshold: <!--
 Local variables:
 mode: sgml
 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
index c84424845cf2f3117ed8716a3e81fdbc69857485..3509f766817b52956c5138497863593d4484af66 100644 (file)
@@ -28,7 +28,6 @@ Utility and miscellaneous convenience functions.
 @g: 
 @b: 
 @Returns: 
-
 <!--
 Local variables:
 mode: sgml
index 3dba5882361381a281b40ad5bba11be77fe8103c..cdd3f4bd59a44917ff300ea0f3f6b8d0c31f1cb0 100644 (file)
@@ -1,3 +1,46 @@
+2000-01-01  Federico Mena Quintero  <federico@helixcode.com>
+
+       * gdk-pixbuf/gdk-pixbuf.h (GdkPixbufAnimation): Added reference
+       counting to animations.  A web browser may want to share a single
+       copy of an animated GIF if it appears multiple times in a web
+       page, for example.
+
+       * gdk-pixbuf/gdk-pixbuf-animation.c: New file.  Moved the
+       animation functions here.
+       (gdk_pixbuf_animation_new_from_file): Prettified.  Return a NULL
+       animation if the loader does not support multiframe loading and
+       the single-frame load returned NULL.  Check that the filename is
+       not NULL.  Updated inline documentation.
+       (gdk_pixbuf_animation_ref): New function.
+       (gdk_pixbuf_animation_unref): New function.
+       Removed gdk_pixbuf_animation_destroy() in favor of reference
+       counting.
+
+       * gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_new_from_file):
+       Prettified.  Made ref_count assertion more paranoid.  Check that
+       the filename is not NULL.
+       (gdk_pixbuf_get_module): Use guchar * and guint for buffer and
+       size, respectively.
+       (gdk_pixbuf_new_from_xpm_data): Changed the "data" argument to
+       const char **.
+
+       * gdk-pixbuf/io-gif.c (image_load_animation): Create the animation
+       with a reference count of 1.
+
+       * gdk-pixbuf/Makefile.am (libgdk_pixbuf_la_SOURCES): Added
+       gdk-pixbuf-animation.c.
+
+       * doc/tmpl/animation.sgml: Populated.  It is still missing a
+       description of the overlay modes.
+
+       * doc/gdk-pixbuf-sections.txt: Added the animation section.  Moved
+       the canvas item section to the end, as it will be moved later to
+       gnome-libs.
+
+       * doc/gdk-pixbuf.sgml: Added the animation section.
+
+       * doc/Makefile.am (tmpl_sources): Added tmpl/animation.sgml.
+
 1999-12-26  Peter Teichman  <pat@gnu.org>
 
        * gdk-pixbuf/Makefile.am (libpixbuf_tiff_la_LIBADD): add
 
 1999-12-08  Arjan van de Ven <arjan@fenrus.demon.nl>
 
-       * gdk-pixbuf/gdk-pixbuf-drawable.c : Fixed the red/green/red 
+       * gdk-pixbuf/gdk-pixbuf-drawable.c : Fixed the red/green/red
        bug on two occasions.
-       * gdk-pixbuf/io-ras.c: Changed from the custom be32_to_cpu 
+       * gdk-pixbuf/io-ras.c: Changed from the custom be32_to_cpu
        function to the generic glib one.
 
 1999-12-08  Federico Mena Quintero  <federico@redhat.com>
index cb08a116d807fa91e53abb29610a4fa384a2c008..3dd9bf9f609285d1fe0b462f4eb28ae7eaffe587 100644 (file)
@@ -52,17 +52,11 @@ LDADDS = libgdk_pixbuf.la $(LIBART_LIBS) $(GLIB_LIBS) $(GTK_LIBS)
 if INSIDE_GNOME_LIBS
 testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule
 testpixbuf_drawable_LDADD = $(LDADDS)
+testanimation_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule
 else
 testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule
 testpixbuf_drawable_LDADD = $(LDADDS) $(GNOME_LIBS)
-endif
-
-if INSIDE_GNOME_LIBS
-testanimation_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule
-testanimation_drawable_LDADD = $(LDADDS)
-else
 testanimation_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule
-testanimation_drawable_LDADD = $(LDADDS) $(GNOME_LIBS)
 endif
 
 
@@ -83,6 +77,7 @@ libgdk_pixbufincludedir = $(includedir)/gdk-pixbuf
 
 libgdk_pixbuf_la_SOURCES =     \
        gdk-pixbuf.c            \
+       gdk-pixbuf-animation.c  \
        gdk-pixbuf-data.c       \
        gdk-pixbuf-drawable.c   \
        gdk-pixbuf-io.c         \
diff --git a/gdk-pixbuf/gdk-pixbuf-animation.c b/gdk-pixbuf/gdk-pixbuf-animation.c
new file mode 100644 (file)
index 0000000..3a693cc
--- /dev/null
@@ -0,0 +1,159 @@
+/* GdkPixbuf library - Simple animation support
+ *
+ * Copyright (C) 1999 The Free Software Foundation
+ *
+ * Authors: Jonathan Blandford <jrb@redhat.com>
+ *          Havoc Pennington <hp@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include "gdk-pixbuf-io.h"
+
+\f
+
+/**
+ * gdk_pixbuf_animation_new_from_file:
+ * @filename: Name of file to load.
+ *
+ * Creates a new animation by loading it from a file.  The file format is
+ * detected automatically.  If the file's format does not support multi-frame
+ * images, then an animation with a single frame will be created.
+ *
+ * Return value: A newly created animation with a reference count of 1, or NULL
+ * if any of several error conditions ocurred:  the file could not be opened,
+ * there was no loader for the file's format, there was not enough memory to
+ * allocate the image buffer, or the image file contained invalid data.
+ **/
+GdkPixbufAnimation *
+gdk_pixbuf_animation_new_from_file (const char *filename)
+{
+       GdkPixbufAnimation *animation;
+       int size;
+       FILE *f;
+       guchar buffer [128];
+       GdkPixbufModule *image_module;
+
+       g_return_val_if_fail (filename != NULL, NULL);
+
+       f = fopen (filename, "r");
+       if (!f)
+               return NULL;
+
+       size = fread (&buffer, 1, sizeof (buffer), f);
+
+       if (size == 0) {
+               fclose (f);
+               return NULL;
+       }
+
+       image_module = gdk_pixbuf_get_module (buffer, size);
+       if (!image_module) {
+               g_warning ("Unable to find handler for file: %s", filename);
+               fclose (f);
+               return NULL;
+       }
+
+       if (image_module->module == NULL)
+               gdk_pixbuf_load_module (image_module);
+
+       if (image_module->load_animation == NULL) {
+               GdkPixbuf *pixbuf;
+               GdkPixbufFrame *frame;
+
+               /* Keep this logic in sync with gdk_pixbuf_new_from_file() */
+
+               if (image_module->load == NULL) {
+                       fclose (f);
+                       return NULL;
+               }
+
+               fseek (f, 0, SEEK_SET);
+               pixbuf = (* image_module->load) (f);
+               fclose (f);
+
+               if (pixbuf)
+                       g_assert (pixbuf->ref_count > 0);
+               else
+                       return NULL;
+
+               frame = g_new (GdkPixbufFrame, 1);
+               frame->pixbuf = pixbuf;
+               frame->x_offset = 0;
+               frame->y_offset = 0;
+               frame->delay_time = -1;
+               frame->action = GDK_PIXBUF_FRAME_RETAIN;
+
+               animation = g_new (GdkPixbufAnimation, 1);
+               animation->ref_count = 1;
+               animation->n_frames = 1;
+               animation->frames = g_list_prepend (NULL, frame);
+       } else {
+               fseek (f, 0, SEEK_SET);
+               animation = (* image_module->load_animation) (f);
+               fclose (f);
+       }
+
+       return animation;
+}
+
+/**
+ * gdk_pixbuf_animation_ref:
+ * @animation: An animation.
+ *
+ * Adds a reference to an animation.  It must be released afterwards using
+ * gdk_pixbuf_animation_unref().
+ **/
+void
+gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation)
+{
+       g_return_if_fail (animation != NULL);
+       g_return_if_fail (animation->ref_count > 0);
+
+       animation->ref_count++;
+}
+
+/**
+ * gdk_pixbuf_animation_unref:
+ * @animation: An animation.
+ * 
+ * Removes a reference from an animation.  It will be destroyed when the
+ * reference count drops to zero.  At that point, all the frames in the
+ * animation will be freed and their corresponding pixbufs will be unreferenced.
+ **/
+void
+gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation)
+{
+       g_return_if_fail (animation != NULL);
+       g_return_if_fail (animation->ref_count > 0);
+
+       animation->ref_count--;
+
+       if (animation->ref_count == 0) {
+               GList *l;
+               GdkPixbufFrame *frame;
+
+               for (l = animation->frames; l; l = l->next) {
+                       frame = l->data;
+                       gdk_pixbuf_unref (frame->pixbuf);
+                       g_free (frame);
+               }
+
+               g_list_free (animation->frames);
+               g_free (animation);
+       }
+}
index 7542311d509d107f93f139d36c6b4a88d9b79ed7..71fcf81b74afe79dc46041cfc5819445d9e3ad3c 100644 (file)
@@ -193,7 +193,7 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module)
        GModule *module;
        gpointer load_sym;
 
-        g_return_if_fail(image_module->module == NULL);
+        g_return_if_fail (image_module->module == NULL);
 
        module_name = g_strconcat ("pixbuf-", image_module->module_name, NULL);
        path = g_module_build_path (PIXBUF_LIBDIR, module_name);
@@ -201,17 +201,17 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module)
        module = g_module_open (path, G_MODULE_BIND_LAZY);
        if (!module) {
                 /* Debug feature, check in present working directory */
-                g_free(path);
-                path = g_module_build_path("", module_name);
-                module = g_module_open(path, G_MODULE_BIND_LAZY);
+                g_free (path);
+                path = g_module_build_path ("", module_name);
+                module = g_module_open (path, G_MODULE_BIND_LAZY);
 
                 if (!module) {
-                        g_warning ("Unable to load module: %s: %s", path, g_module_error());
+                        g_warning ("Unable to load module: %s: %s", path, g_module_error ());
                         g_free (module_name);
-                        g_free(path);
+                        g_free (path);
                         return;
                 }
-                g_free(path);
+                g_free (path);
        } else {
                 g_free (path);
         }
@@ -242,14 +242,15 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module)
 \f
 
 GdkPixbufModule *
-gdk_pixbuf_get_module (gchar *buffer, gint size)
+gdk_pixbuf_get_module (guchar *buffer, guint size)
 {
-       gint i;
+       int i;
 
        for (i = 0; file_formats [i].module_name; i++) {
                if ((* file_formats [i].format_check) (buffer, size))
                        return &(file_formats[i]);
        }
+
        return NULL;
 }
 
@@ -269,46 +270,46 @@ GdkPixbuf *
 gdk_pixbuf_new_from_file (const char *filename)
 {
        GdkPixbuf *pixbuf;
-       gint size;
+       int size;
        FILE *f;
-       char buffer [128];
+       guchar buffer [128];
        GdkPixbufModule *image_module;
 
+       g_return_val_if_fail (filename != NULL, NULL);
+
        f = fopen (filename, "r");
        if (!f)
                return NULL;
 
        size = fread (&buffer, 1, sizeof (buffer), f);
-
        if (size == 0) {
                fclose (f);
                return NULL;
        }
 
        image_module = gdk_pixbuf_get_module (buffer, size);
-       if (image_module){
-               if (image_module->module == NULL)
-                       gdk_pixbuf_load_module (image_module);
-
-               if (image_module->load == NULL) {
-                       fclose (f);
-                       return NULL;
-               }
-
-               fseek (f, 0, SEEK_SET);
-               pixbuf = (* image_module->load) (f);
+       if (!image_module) {
+               g_warning ("Unable to find handler for file: %s", filename);
                fclose (f);
+               return NULL;
+       }
 
-               if (pixbuf)
-                       g_assert (pixbuf->ref_count != 0);
+       if (image_module->module == NULL)
+               gdk_pixbuf_load_module (image_module);
 
-               return pixbuf;
-       } else {
-               g_warning ("Unable to find handler for file: %s", filename);
+       if (image_module->load == NULL) {
+               fclose (f);
+               return NULL;
        }
 
+       fseek (f, 0, SEEK_SET);
+       pixbuf = (* image_module->load) (f);
        fclose (f);
-       return NULL;
+
+       if (pixbuf)
+               g_assert (pixbuf->ref_count > 0);
+
+       return pixbuf;
 }
 
 /**
@@ -321,98 +322,23 @@ gdk_pixbuf_new_from_file (const char *filename)
  * Return value: A newly-created pixbuf with a reference count of 1.
  **/
 GdkPixbuf *
-gdk_pixbuf_new_from_xpm_data (const gchar **data)
+gdk_pixbuf_new_from_xpm_data (const char **data)
 {
-        GdkPixbuf *(* load_xpm_data) (const gchar **data);
-        GdkPixbuf *pixbuf;
-
-        if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL) {
-                gdk_pixbuf_load_module(&file_formats[XPM_FILE_FORMAT_INDEX]);
-        }
-
-        if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL) {
-                g_warning("Can't find gdk-pixbuf module for parsing inline XPM data");
-                return NULL;
-        } else if (file_formats[XPM_FILE_FORMAT_INDEX].load_xpm_data == NULL) {
-                g_warning("gdk-pixbuf XPM module lacks XPM data capability");
-                return NULL;
-        } else {
-                load_xpm_data = file_formats[XPM_FILE_FORMAT_INDEX].load_xpm_data;
-        }
-
-        pixbuf = load_xpm_data(data);
-
-        return pixbuf;
-}
-
+       GdkPixbuf *(* load_xpm_data) (const char **data);
+       GdkPixbuf *pixbuf;
 
-/**
- * gdk_pixbuf_animation_new_from_file:
- * @filename: The filename.
- * 
- * Creates a new @GdkPixbufAnimation with @filename loaded as the animation.  If
- * @filename doesn't exist or is an invalid file, the @n_frames member will be
- * 0.  If @filename is a static image (and not an animation) then the @n_frames
- * member will be 1.
- * 
- * Return value: A newly created GdkPixbufAnimation.
- **/
-GdkPixbufAnimation *
-gdk_pixbuf_animation_new_from_file (const gchar *filename)
-{
-       GdkPixbufAnimation *animation;
-       gint size;
-       FILE *f;
-       char buffer [128];
-       GdkPixbufModule *image_module;
+       if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL)
+               gdk_pixbuf_load_module (&file_formats[XPM_FILE_FORMAT_INDEX]);
 
-       f = fopen (filename, "r");
-       if (!f)
+       if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL) {
+               g_warning ("Can't find gdk-pixbuf module for parsing inline XPM data");
                return NULL;
-
-       size = fread (&buffer, 1, sizeof (buffer), f);
-
-       if (size == 0) {
-               fclose (f);
+       } else if (file_formats[XPM_FILE_FORMAT_INDEX].load_xpm_data == NULL) {
+               g_warning ("gdk-pixbuf XPM module lacks XPM data capability");
                return NULL;
-       }
+       } else
+               load_xpm_data = file_formats[XPM_FILE_FORMAT_INDEX].load_xpm_data;
 
-       image_module = gdk_pixbuf_get_module (buffer, size);
-       if (image_module){
-               if (image_module->module == NULL)
-                       gdk_pixbuf_load_module (image_module);
-
-               if (image_module->load_animation == NULL) {
-                       GdkPixbufFrame *frame;
-                       if (image_module->load == NULL) {
-                               fclose (f);
-                               return NULL;
-                       }
-                       animation = g_new (GdkPixbufAnimation, 1);
-                       frame = g_new (GdkPixbufFrame, 1);
-
-                       animation->n_frames = 1;
-                       animation->frames = g_list_prepend (NULL, (gpointer) frame);
-
-                       frame->x_offset = 0;
-                       frame->y_offset = 0;
-                       frame->delay_time = -1;
-                       frame->action = GDK_PIXBUF_FRAME_RETAIN;
-
-                       fseek (f, 0, SEEK_SET);
-                       frame->pixbuf = (* image_module->load) (f);
-                       fclose (f);
-               } else {
-                       fseek (f, 0, SEEK_SET);
-                       animation = (* image_module->load_animation) (f);
-                       fclose (f);
-               }
-
-               return animation;
-       } else {
-               g_warning ("Unable to find handler for file: %s", filename);
-       }
-
-       fclose (f);
-       return NULL;
+       pixbuf = (* load_xpm_data) (data);
+       return pixbuf;
 }
index 4aa9ed35eb389761eee54b31f48e52b316ba656e..966768f1a5fdff5fd29785d6468bf5c6017c7928 100644 (file)
@@ -38,7 +38,9 @@ extern "C" {
 \f
 
 typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
-typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data, guint x, guint y, guint width, guint height);
+typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data,
+                                         guint x, guint y,
+                                         guint width, guint height);
 
 typedef struct _GdkPixbufModule GdkPixbufModule;
 struct _GdkPixbufModule {
@@ -46,22 +48,23 @@ struct _GdkPixbufModule {
        gboolean (* format_check) (guchar *buffer, int size);
        GModule *module;
        GdkPixbuf *(* load) (FILE *f);
-        GdkPixbuf *(* load_xpm_data) (const gchar **data);
+        GdkPixbuf *(* load_xpm_data) (const char **data);
 
         /* Incremental loading */
-        gpointer   (* begin_load)    (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, gpointer user_data);
-        void       (* stop_load)     (gpointer context);
-        gboolean   (* load_increment)(gpointer context, const gchar *buf, guint size);
+
+        gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func,
+                                ModuleUpdatedNotifyFunc update_func,
+                                gpointer user_data);
+        void (* stop_load) (gpointer context);
+        gboolean (* load_increment) (gpointer context, const guchar *buf, guint size);
 
        /* Animation loading */
        GdkPixbufAnimation *(* load_animation) (FILE *f);
 };
 
 
-GdkPixbufModule *gdk_pixbuf_get_module  (gchar           *buffer,
-                                        gint             size);
-void             gdk_pixbuf_load_module (GdkPixbufModule *image_module);
-
+GdkPixbufModule *gdk_pixbuf_get_module (guchar *buffer, guint size);
+void gdk_pixbuf_load_module (GdkPixbufModule *image_module);
 
 \f
 
index e5b81f1ee8aeab14a5e7d0fc373df0504e1d45fb..3d2243662a0f328060d05baea583e57a6d7b37e8 100644 (file)
@@ -58,7 +58,7 @@ typedef struct {
        GdkPixbuf *pixbuf;
        GdkPixbufAnimation *animation;
        gboolean closed;
-       gchar header_buf[LOADER_HEADER_SIZE];
+       guchar header_buf[LOADER_HEADER_SIZE];
        gint header_buf_offset;
        GdkPixbufModule *image_module;
        gpointer context;
@@ -290,7 +290,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
 }
 
 static int
-gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const gchar *buf, size_t count)
+gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const guchar *buf, size_t count)
 {
        int nbytes;
        GdkPixbufLoaderPrivate *priv = loader->private;
@@ -321,7 +321,7 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const gchar *buf, s
  * cannot parse the buffer.
  **/
 gboolean
-gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const gchar *buf, size_t count)
+gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const guchar *buf, size_t count)
 {
        GdkPixbufLoaderPrivate *priv;
 
index 1ba263b5784d036f117952875f5f0b127dc172c5..bbab22e11e4496a4c23b742d7453c7ab2b49d66b 100644 (file)
@@ -73,7 +73,7 @@ struct _GdkPixbufLoaderClass {
 GtkType             gdk_pixbuf_loader_get_type      (void);
 GdkPixbufLoader    *gdk_pixbuf_loader_new           (void);
 gboolean            gdk_pixbuf_loader_write         (GdkPixbufLoader *loader,
-                                                    const gchar     *buf,
+                                                    const guchar    *buf,
                                                     size_t           count);
 GdkPixbuf          *gdk_pixbuf_loader_get_pixbuf    (GdkPixbufLoader *loader);
 GdkPixbufAnimation *gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader);
index eea251050efe59eb2a89e82c8b330935238b3bb7..329de797c2dde8c533db2417b34d2a39e3397653 100644 (file)
@@ -167,11 +167,10 @@ gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
 ArtPixFormat
 gdk_pixbuf_get_format (GdkPixbuf *pixbuf)
 {
-       /* Unfortunately, there's nothing else to return */
        g_return_val_if_fail (pixbuf != NULL, ART_PIX_RGB);
        g_assert (pixbuf->art_pixbuf != NULL);
 
-       return (pixbuf->art_pixbuf->format);
+       return pixbuf->art_pixbuf->format;
 }
 
 /**
@@ -188,7 +187,7 @@ gdk_pixbuf_get_n_channels (GdkPixbuf *pixbuf)
        g_return_val_if_fail (pixbuf != NULL, -1);
        g_assert (pixbuf->art_pixbuf != NULL);
 
-       return (pixbuf->art_pixbuf->n_channels);
+       return pixbuf->art_pixbuf->n_channels;
 }
 
 /**
@@ -205,7 +204,7 @@ gdk_pixbuf_get_has_alpha (GdkPixbuf *pixbuf)
        g_return_val_if_fail (pixbuf != NULL, -1);
        g_assert (pixbuf->art_pixbuf != NULL);
 
-       return (pixbuf->art_pixbuf->has_alpha);
+       return pixbuf->art_pixbuf->has_alpha;
 }
 
 /**
@@ -222,7 +221,7 @@ gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf)
        g_return_val_if_fail (pixbuf != NULL, -1);
        g_assert (pixbuf->art_pixbuf != NULL);
 
-       return (pixbuf->art_pixbuf->bits_per_sample);
+       return pixbuf->art_pixbuf->bits_per_sample;
 }
 
 /**
@@ -239,7 +238,7 @@ gdk_pixbuf_get_pixels (GdkPixbuf *pixbuf)
        g_return_val_if_fail (pixbuf != NULL, NULL);
        g_assert (pixbuf->art_pixbuf != NULL);
 
-       return (pixbuf->art_pixbuf->pixels);
+       return pixbuf->art_pixbuf->pixels;
 }
 
 /**
@@ -256,7 +255,7 @@ gdk_pixbuf_get_width (GdkPixbuf *pixbuf)
        g_return_val_if_fail (pixbuf != NULL, -1);
        g_assert (pixbuf->art_pixbuf != NULL);
 
-       return (pixbuf->art_pixbuf->width);
+       return pixbuf->art_pixbuf->width;
 }
 
 /**
@@ -273,7 +272,7 @@ gdk_pixbuf_get_height (GdkPixbuf *pixbuf)
        g_return_val_if_fail (pixbuf != NULL, -1);
        g_assert (pixbuf->art_pixbuf != NULL);
 
-       return (pixbuf->art_pixbuf->height);
+       return pixbuf->art_pixbuf->height;
 }
 
 /**
@@ -290,33 +289,5 @@ gdk_pixbuf_get_rowstride (GdkPixbuf *pixbuf)
        g_return_val_if_fail (pixbuf != NULL, -1);
        g_assert (pixbuf->art_pixbuf != NULL);
 
-       return (pixbuf->art_pixbuf->rowstride);
+       return pixbuf->art_pixbuf->rowstride;
 }
-
-/**
- * gdk_pixbuf_animation_destroy:
- * @animation: An animation.
- * @free_frames: Keep the frames.
- * 
- * Destroys the animation.  If @free_frames is set, then the actual image data
- * will be free'd as well.
- *
- **/
-void
-gdk_pixbuf_animation_destroy (GdkPixbufAnimation *animation,
-                             gboolean free_frames)
-{
-       GList *ptr;
-
-       g_return_if_fail (animation != NULL);
-
-       for (ptr = animation->frames; ptr; ptr = g_list_next (ptr)) {
-               if (free_frames)
-                       gdk_pixbuf_unref (((GdkPixbufFrame *)ptr->data)->pixbuf);
-               g_free (ptr->data);
-       }
-       g_list_free (animation->frames);
-
-       g_free (animation);
-}
-
index ff93c25d00ebb3776286d4a401f768a9e8273a9c..7a30f3c8eda0ba4351b20bf849248e63e6a77c0d 100644 (file)
@@ -40,15 +40,7 @@ typedef struct _GdkPixbuf GdkPixbuf;
 typedef struct _GdkPixbufFrame GdkPixbufFrame;
 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
 
-typedef enum
-{
-       GDK_PIXBUF_FRAME_RETAIN,
-       GDK_PIXBUF_FRAME_DISPOSE,
-       GDK_PIXBUF_FRAME_REVERT
-} GdkPixbufFrameAction;
-
-struct _GdkPixbuf
-{
+struct _GdkPixbuf {
        /* Reference count */
        int ref_count;
 
@@ -56,21 +48,36 @@ struct _GdkPixbuf
        ArtPixBuf *art_pixbuf;
 };
 
+/* GIF-like animation overlay modes for frames */
+typedef enum {
+       GDK_PIXBUF_FRAME_RETAIN,
+       GDK_PIXBUF_FRAME_DISPOSE,
+       GDK_PIXBUF_FRAME_REVERT
+} GdkPixbufFrameAction;
 
-struct _GdkPixbufFrame
-{
+struct _GdkPixbufFrame {
+       /* The pixbuf with this frame's image data */
        GdkPixbuf *pixbuf;
 
-       gushort x_offset;
-       gushort y_offset;
-       gint delay_time;
+       /* Offsets for overlaying onto the animation's area */
+       int x_offset;
+       int y_offset;
+
+       /* Frame duration in ms */
+       int delay_time;
+
+       /* Overlay mode */
        GdkPixbufFrameAction action;
 };
 
+struct _GdkPixbufAnimation {
+       /* Reference count */
+       int ref_count;
 
-struct _GdkPixbufAnimation
-{
+       /* Number of frames */
         int n_frames;
+
+       /* List of GdkPixbufFrame structures */
         GList *frames;
 };
 
@@ -92,35 +99,34 @@ int          gdk_pixbuf_get_rowstride       (GdkPixbuf *pixbuf);
 void gdk_pixbuf_ref (GdkPixbuf *pixbuf);
 void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
 
-/* Constructors */
 /* Wrap a libart pixbuf */
-
 GdkPixbuf *gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf);
 
 /* Create a blank pixbuf with an optimal rowstride and a new buffer */
-
 GdkPixbuf *gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
                           int width, int height);
 
 /* Simple loading */
 
-GdkPixbuf *gdk_pixbuf_new_from_file     (const char        *filename);
-GdkPixbuf *gdk_pixbuf_new_from_data     (guchar *data,
-                                        ArtPixFormat format,
-                                        gboolean has_alpha,
-                                        int width, int height,
-                                        int rowstride,
-                                        ArtDestroyNotify dfunc,
-                                        gpointer dfunc_data);
-GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const gchar      **data);
+GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
+
+GdkPixbuf *gdk_pixbuf_new_from_data (guchar *data,
+                                    ArtPixFormat format,
+                                    gboolean has_alpha,
+                                    int width, int height,
+                                    int rowstride,
+                                    ArtDestroyNotify dfunc,
+                                    gpointer dfunc_data);
 
-/* Adding or removing alpha */
+GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
 
+/* Adding an alpha channel */
 GdkPixbuf *gdk_pixbuf_add_alpha (GdkPixbuf *pixbuf, gboolean substitute_color,
                                 guchar r, guchar g, guchar b);
 
 /* Rendering to a drawable */
 
+/* Alpha compositing mode */
 typedef enum {
        GDK_PIXBUF_ALPHA_BILEVEL,
        GDK_PIXBUF_ALPHA_FULL
@@ -149,7 +155,6 @@ void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawab
                                          GdkRgbDither dither,
                                          int x_dither, int y_dither);
 
-
 /* Fetching a region from a drawable */
 GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
                                         GdkDrawable *src, GdkColormap *cmap,
@@ -157,14 +162,12 @@ GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
                                         int dest_x, int dest_y,
                                         int width, int height);
 
-\f
-
-/* Animation loading */
+/* Animation support */
 
-GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char         *filename);
-void                gdk_pixbuf_animation_destroy       (GdkPixbufAnimation *animation,
-                                                       gboolean            free_frames);
+GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename);
 
+void gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation);
+void gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation);
 
 \f
 
index c36809ba0ad6978cd2633487c05b08b5710b6807..467df06824eb2164c637e884a534886ba58d0137 100644 (file)
@@ -210,7 +210,7 @@ gif_read (GifContext *context, guchar *buffer, size_t len)
                return retval;
        } else {
 #ifdef IO_GIFDEBUG
-//             g_print ("\tlooking for %d bytes.  size == %d, ptr == %d\n", len, context->size, context->ptr);
+/*             g_print ("\tlooking for %d bytes.  size == %d, ptr == %d\n", len, context->size, context->ptr); */
 #endif
                if ((context->size - context->ptr) >= len) {
 #ifdef IO_GIFDEBUG
@@ -378,7 +378,7 @@ static int
 GetDataBlock (GifContext *context,
              unsigned char *buf)
 {
-//     unsigned char count;
+/*     unsigned char count; */
 
        if (!gif_read (context, &context->block_count, 1)) {
                /*g_message (_("GIF: error in getting DataBlock size\n"));*/
@@ -1107,9 +1107,11 @@ image_stop_load (gpointer data)
 {
        GifContext *context = (GifContext *) data;
 
+       /* FIXME: free the animation data */
+
        if (context->pixbuf)
                gdk_pixbuf_unref (context->pixbuf);
-//     g_free (context->buf);
+/*     g_free (context->buf); */
        g_free (context);
 }
 
@@ -1180,6 +1182,7 @@ image_load_animation (FILE *file)
 
        context = new_context ();
        context->animation = g_new (GdkPixbufAnimation, 1);
+       context->animation->ref_count = 1;
        context->animation->n_frames = 0;
        context->animation->frames = NULL;
        context->file = file;
index e645130f777c03129cb653dd1ce3cb30831ec152..a6adbc95aba6464ebfb10258c08be2094f8ecc5d 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Authors: Michael Zucchi <zucchi@zedzone.mmc.com.au>
  *          Cody Russell <bratsche@dfw.net>
- *         Federico
+ *         Federico Mena-Quintero <federico@gimp.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -952,7 +952,7 @@ rgbconvert (GdkImage *image, art_u8 *pixels, int rowstride, int alpha, GdkColorm
                        if (v->red_mask == 0xf800 && v->green_mask == 0x7e0 && v->blue_mask == 0x1f
                            && image->bpp == 16)
                                bank = 3;
-                       break;                  
+                       break;
                case 24:
                case 32:
                        if (v->red_mask == 0xff0000 && v->green_mask == 0xff00 && v->blue_mask == 0xff
@@ -1030,7 +1030,7 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
                              int width, int height)
 {
        GdkWindowType window_type;
-       gint src_width, src_height;
+       int src_width, src_height;
        ArtPixBuf *apb = NULL;
        GdkImage *image;
        int rowstride, bpp, alpha;
@@ -1076,7 +1076,7 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
 
        if (window_type != GDK_WINDOW_PIXMAP) {
                int ret;
-               gint src_xorigin, src_yorigin;
+               int src_xorigin, src_yorigin;
                int screen_width, screen_height;
                int screen_srcx, screen_srcy;
 
index e5b81f1ee8aeab14a5e7d0fc373df0504e1d45fb..3d2243662a0f328060d05baea583e57a6d7b37e8 100644 (file)
@@ -58,7 +58,7 @@ typedef struct {
        GdkPixbuf *pixbuf;
        GdkPixbufAnimation *animation;
        gboolean closed;
-       gchar header_buf[LOADER_HEADER_SIZE];
+       guchar header_buf[LOADER_HEADER_SIZE];
        gint header_buf_offset;
        GdkPixbufModule *image_module;
        gpointer context;
@@ -290,7 +290,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
 }
 
 static int
-gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const gchar *buf, size_t count)
+gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const guchar *buf, size_t count)
 {
        int nbytes;
        GdkPixbufLoaderPrivate *priv = loader->private;
@@ -321,7 +321,7 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const gchar *buf, s
  * cannot parse the buffer.
  **/
 gboolean
-gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const gchar *buf, size_t count)
+gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const guchar *buf, size_t count)
 {
        GdkPixbufLoaderPrivate *priv;
 
index 1ba263b5784d036f117952875f5f0b127dc172c5..bbab22e11e4496a4c23b742d7453c7ab2b49d66b 100644 (file)
@@ -73,7 +73,7 @@ struct _GdkPixbufLoaderClass {
 GtkType             gdk_pixbuf_loader_get_type      (void);
 GdkPixbufLoader    *gdk_pixbuf_loader_new           (void);
 gboolean            gdk_pixbuf_loader_write         (GdkPixbufLoader *loader,
-                                                    const gchar     *buf,
+                                                    const guchar    *buf,
                                                     size_t           count);
 GdkPixbuf          *gdk_pixbuf_loader_get_pixbuf    (GdkPixbufLoader *loader);
 GdkPixbufAnimation *gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader);